<?php

if (!class_exists('WPLMS_Customizer_Plugin_Class')) {

    class WPLMS_Customizer_Plugin_Class
    {
        public function __construct()
        {

            add_filter('vibe_builder_thumb_styles', array($this, 'custom_vibe_builder_thumb_styles'));
            add_filter('vibe_featured_thumbnail_style', array($this, 'custom_vibe_featured_thumbnail_style'), 10, 3);
        } // END public function __construct

        function custom_vibe_builder_thumb_styles($thumb_array)
        {
            //课程的style course-1
            $thumb_array['custom_block'] = 'https://i.imgur.com/gxrPvvJ.jpg';
            //exam的style
            $thumb_array['custom_exam_style'] = 'http://localhost/wordpress/wp-content/uploads/2018/04/下载.jpg';

            return $thumb_array;
        }

        function custom_vibe_featured_thumbnail_style($thumbnail_html, $post, $style)
        {
            $thumbnail_html = '';
            if ($style == 'custom_block') { //Custom block is the same name as added for the thumbnail in pagebuilder
                $thumbnail_html = '';
                $thumbnail_html .= '<div class="block modern_course">';
                $thumbnail_html .= '<div class="block_media">';
                $thumbnail_html .= '<a href="'.get_permalink($post->ID).'">'.get_the_post_thumbnail(
                        $post->ID,
                        'medium'
                    ).'</a>';
                $thumbnail_html .= '</div>';
                $thumbnail_html .= '<div class="block_content">';
                $thumbnail_html .= '<h4 class="block_title"><a href="'.get_permalink(
                        $post->ID
                    ).'" title="'.$post->post_title.'">'.$post->post_title.'</a></h4>';

                $terms = get_the_terms($post->ID, 'course-cat');
                foreach ($terms as $term) {
                    $thumbnail_html .= '<span>';
                    $thumbnail_html .= '<a href="http://www.baidu.com" title="'.$post->post_title.'" >'.$term->name.' </a>';
                    $thumbnail_html .= '</span>';
                }
                $thumbnail_html .= '</div></div>';
            } elseif ($style == 'custom_exam_style') {
                $thumbnail_html .= '<div class="block side">';
                $thumbnail_html .= '<div class="block_content">';
                $thumbnail_html .= '<h4 class="block_title"><a href="'.get_permalink(
                        $post->ID
                    ).'" title="'.$post->post_title.'">'.$post->post_title.'</a></h4>';
                $thumbnail_html .='<p class="block_desc">'.vibe_custom_types_excerpt(100, $post->ID).'</p>';
                $thumbnail_html .= '</div>';
                $thumbnail_html .= '</div>';

            }

            return $thumbnail_html;
        }

    } // END class WPLMS_Customizer_Class
} // END if(!class_exists('WPLMS_Customizer_Class'))
?>